package casbinApi

import (
	"github.com/Sir-yuChen/funAnalyse/model"
	"github.com/Sir-yuChen/funAnalyse/model/common/response"
	"github.com/Sir-yuChen/funAnalyse/model/request"
	"github.com/Sir-yuChen/funAnalyse/utils"
	"github.com/gin-gonic/gin"
)

type StockDeptController struct{}

// GetStockDept 多条件查询
// @Summary stockDept get
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockDeptModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/getCasbinDept [GET]
func (b *StockDeptController) GetStockDept(c *gin.Context) {
	var req model.StockDeptModel
	if err := c.ShouldBindJSON(&req); err != nil {
		utils.ErrValidatorResp(err, "GetStockDept", req, c)
		return
	}
	apiReturn := stockDeptService.GetStockDept(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// InsertStockDept
// @Summary stockDept insert
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body request.InsterDeptRequest true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/insertCasbinDept [POST]
func (b *StockDeptController) InsertStockDept(c *gin.Context) {
	var req request.InsterDeptRequest
	if err := c.ShouldBindJSON(&req); err != nil {
		utils.ErrValidatorResp(err, "InsertStockDept", req, c)
		return
	}
	apiReturn := stockDeptService.InsertStockDept(&req, c)
	response.WithApiReturn(apiReturn, c)
	return
}

// UpdateStockDept
// @Summary stockDept update
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockDeptModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/updateCasbinDept [POST]
func (b *StockDeptController) UpdateStockDept(c *gin.Context) {
	var req model.StockDeptModel
	if err := c.ShouldBindJSON(&req); err != nil {
		utils.ErrValidatorResp(err, "UpdateStockDept", req, c)
		return
	}
	apiReturn := stockDeptService.UpdateStockDept(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// DelStockDept
// @Summary stockDept del
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockDeptModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/delCasbinDept [Get]
func (b *StockDeptController) DelStockDept(c *gin.Context) {
	var req model.StockDeptModel
	if err := c.ShouldBindJSON(&req); err != nil {
		utils.ErrValidatorResp(err, "DelStockDept", req, c)
		return
	}
	apiReturn := stockDeptService.DelStockDept(&req)
	response.WithApiReturn(apiReturn, c)
	return
}
